Skip to content

Commit 9099318

Browse files
authored
Add NO_AUDIO signal to theater (#381)
* send no audio signal if there is no audio * update cicd instructions
1 parent 31a7806 commit 9099318

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

cicd/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ Notes:
5656
* your branch name cannot contain the character `/`, as this causes issues in AWS. Note that resources will be deployed with the tags `{EnvType = development}`.
5757
* for now, these must deployed to the production AWS account. There is planned work to enable these to be deployed to the Dev AWS account.
5858

59-
```
60-
TARGET_BRANCH=mybranch ENVIRONMENT_TYPE=development cicd/2-cicd/deploy-cicd.sh
61-
```
59+
Steps
60+
61+
- First, login to the AWS production account. You can follow steps 1-3 [here](https://docs.google.com/document/d/1mMQK6HhniLsz9lynzhUcm7Tcw_2WVLBxADe0WzqL6rM/edit#bookmark=id.wtrskofu4rb9) to do so.
62+
- Then, run the following command with your branch name:
63+
```
64+
TARGET_BRANCH=mybranch ENVIRONMENT_TYPE=development cicd/2-cicd/deploy-cicd.sh
65+
```
6266

6367
### Deploying a full CI/CD pipeline for a different branch
6468

org-code-javabuilder/media/src/main/java/org/code/media/support/AudioWriter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public double getTotalAudioLength() {
7676
public void writeToAudioStream() {
7777
if (this.audioSamples.length == 0) {
7878
// Add a silent audio sample so we can build a valid wav file.
79-
// TODO: Send a "No audio" signal instead
8079
this.audioSamples = new double[] {0};
8180
}
8281

org-code-javabuilder/theater/src/main/java/org/code/theater/support/ConcertCreator.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,13 @@ private void pause(double seconds) {
218218
private void writeImageAndAudioToFile() {
219219
this.progressPublisher.onPlay(this.audioWriter.getTotalAudioLength());
220220
this.gifWriter.writeToGif(this.image, 0);
221-
this.audioWriter.writeToAudioStream();
221+
boolean shouldSendAudio = true;
222+
if (this.audioWriter.getTotalAudioLength() == 0) {
223+
shouldSendAudio = false;
224+
this.outputAdapter.sendMessage(new TheaterMessage(TheaterSignalKey.NO_AUDIO, null));
225+
} else {
226+
this.audioWriter.writeToAudioStream();
227+
}
222228

223229
// We must call close() before write so that the streams are flushed.
224230
this.close();
@@ -227,17 +233,21 @@ private void writeImageAndAudioToFile() {
227233
String imageUrl =
228234
this.contentManager.writeToOutputFile(
229235
THEATER_IMAGE_NAME, this.imageOutputStream.toByteArray(), "image/gif");
230-
String audioUrl =
231-
this.contentManager.writeToOutputFile(
232-
THEATER_AUDIO_NAME, this.audioOutputStream.toByteArray(), "audio/wav");
233236

234237
HashMap<String, String> imageMessage = new HashMap<>();
235238
imageMessage.put(URL, imageUrl);
236239
this.outputAdapter.sendMessage(new TheaterMessage(TheaterSignalKey.VISUAL_URL, imageMessage));
237240

238-
HashMap<String, String> audioMessage = new HashMap<>();
239-
audioMessage.put(URL, audioUrl);
240-
this.outputAdapter.sendMessage(new TheaterMessage(TheaterSignalKey.AUDIO_URL, audioMessage));
241+
if (shouldSendAudio) {
242+
String audioUrl =
243+
this.contentManager.writeToOutputFile(
244+
THEATER_AUDIO_NAME, this.audioOutputStream.toByteArray(), "audio/wav");
245+
246+
HashMap<String, String> audioMessage = new HashMap<>();
247+
audioMessage.put(URL, audioUrl);
248+
this.outputAdapter.sendMessage(
249+
new TheaterMessage(TheaterSignalKey.AUDIO_URL, audioMessage));
250+
}
241251
} catch (JavabuilderException e) {
242252
// we should not hit this (caused by too many file writes)
243253
// in normal execution as it is only called via play,

org-code-javabuilder/theater/src/main/java/org/code/theater/support/TheaterSignalKey.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ public enum TheaterSignalKey {
66
// This message contains the url to an audio element
77
AUDIO_URL,
88
// Get an image from the user via Prompter
9-
GET_IMAGE
9+
GET_IMAGE,
10+
// There is no audio for this Theater
11+
NO_AUDIO
1012
}

0 commit comments

Comments
 (0)