Skip to content

Commit ed81178

Browse files
committed
vStream: handle DEVICE and FILENAME registers based on configuration
- this prevents scanning for streaming devices when using file for streaming - emphasizes behavior: files is used when specified instead of streaming device
1 parent 15d9a62 commit ed81178

4 files changed

Lines changed: 36 additions & 5 deletions

File tree

interface/vstream/source/vstream_audio_in.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ static int32_t Initialize (vStreamEvent_t event_cb) {
172172
AudioIn->CONTROL = 0U;
173173

174174
/* Set audio configuration */
175-
AudioIn->DEVICE = AUDIO_IN_DEVICE;
176175
AudioIn->CHANNELS = AUDIO_IN_CHANNELS;
177176
AudioIn->SAMPLE_BITS = AUDIO_IN_SAMPLE_BITS;
178177
AudioIn->SAMPLE_RATE = AUDIO_IN_SAMPLE_RATE;
179178

179+
/* Set filename if specified */
180180
fn = AUDIO_IN_FILENAME;
181181
len = strlen(fn);
182182

@@ -188,6 +188,15 @@ static int32_t Initialize (vStreamEvent_t event_cb) {
188188
for (i = 0; i < len; i++) {
189189
AudioIn->FILENAME = fn[i];
190190
}
191+
192+
if ((AudioIn->STATUS & STATUS_FILE_NAME_Msk) == 0U) {
193+
/* File not found */
194+
return VSTREAM_ERROR;
195+
}
196+
}
197+
else {
198+
/* File not specified, set streaming device */
199+
AudioIn->DEVICE = AUDIO_IN_DEVICE;
191200
}
192201

193202
/* Enable peripheral interrupts */

interface/vstream/source/vstream_audio_out.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,14 @@ static int32_t Initialize (vStreamEvent_t event_cb) {
164164
hAudioOut.eos = 0U;
165165
hAudioOut.flags = 0U;
166166

167-
/* Initialize Audio Input peripheral */
167+
/* Initialize Audio Output peripheral */
168168
AudioOut->Timer.Control = 0U;
169169
AudioOut->DMA.Control = 0U;
170170
AudioOut->IRQ.Clear = IRQ_TIMER_OVERFLOW_Msk;
171171
AudioOut->IRQ.Enable = IRQ_TIMER_OVERFLOW_Msk;
172172
AudioOut->CONTROL = CONTROL_MODE_Msk;
173173

174174
/* Set audio configuration */
175-
AudioOut->DEVICE = AUDIO_OUT_DEVICE;
176175
AudioOut->CHANNELS = AUDIO_OUT_CHANNELS;
177176
AudioOut->SAMPLE_BITS = AUDIO_OUT_SAMPLE_BITS;
178177
AudioOut->SAMPLE_RATE = AUDIO_OUT_SAMPLE_RATE;
@@ -188,6 +187,15 @@ static int32_t Initialize (vStreamEvent_t event_cb) {
188187
for (i = 0; i < len; i++) {
189188
AudioOut->FILENAME = fn[i];
190189
}
190+
191+
if ((AudioOut->STATUS & STATUS_FILE_NAME_Msk) == 0U) {
192+
/* File name is invalid */
193+
return VSTREAM_ERROR;
194+
}
195+
}
196+
else {
197+
/* File not specified, set streaming device */
198+
AudioOut->DEVICE = AUDIO_OUT_DEVICE;
191199
}
192200

193201
/* Enable peripheral interrupts */
@@ -211,7 +219,7 @@ static int32_t Uninitialize (void) {
211219
__DSB();
212220
__ISB();
213221

214-
/* De-initialize Audio Input peripheral */
222+
/* De-initialize Audio Output peripheral */
215223
AudioOut->Timer.Control = 0U;
216224
AudioOut->DMA.Control = 0U;
217225
AudioOut->IRQ.Clear = IRQ_TIMER_OVERFLOW_Msk;

interface/vstream/source/vstream_video_in.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ static int32_t Initialize (vStreamEvent_t event_cb) {
174174
VideoIn->CONTROL = 0U;
175175

176176
/* Set video configuration */
177-
VideoIn->DEVICE = VIDEO_IN_DEVICE;
178177
VideoIn->FRAME_WIDTH = VIDEO_IN_FRAME_WIDTH;
179178
VideoIn->FRAME_HEIGHT = VIDEO_IN_FRAME_HEIGHT;
180179
VideoIn->FRAME_COLOR = VIDEO_IN_FRAME_COLOR;
181180
VideoIn->FRAME_RATE = VIDEO_IN_FRAME_RATE;
182181

182+
/* Set filename if specified */
183183
fn = VIDEO_IN_FILENAME;
184184
len = strlen(fn);
185185

@@ -191,6 +191,15 @@ static int32_t Initialize (vStreamEvent_t event_cb) {
191191
for (i = 0; i < len; i++) {
192192
VideoIn->FILENAME = fn[i];
193193
}
194+
195+
if ((VideoIn->STATUS & STATUS_FILE_NAME_Msk) == 0U) {
196+
/* File not found */
197+
return VSTREAM_ERROR;
198+
}
199+
}
200+
else {
201+
/* File not specified, set streaming device */
202+
VideoIn->DEVICE = VIDEO_IN_DEVICE;
194203
}
195204

196205
/* Enable peripheral interrupts */

interface/vstream/source/vstream_video_out.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ static int32_t Initialize (vStreamEvent_t event_cb) {
189189
for (i = 0; i < len; i++) {
190190
VideoOut->FILENAME = fn[i];
191191
}
192+
193+
if ((VideoOut->STATUS & STATUS_FILE_NAME_Msk) == 0U) {
194+
/* File name is invalid */
195+
return VSTREAM_ERROR;
196+
}
192197
}
193198

194199
/* Enable peripheral interrupts */

0 commit comments

Comments
 (0)