Skip to content

Add NO_AUDIO signal to theater #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cicd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ Notes:
* your branch name cannot contain the character `/`, as this causes issues in AWS. Note that resources will be deployed with the tags `{EnvType = development}`.
* 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.

```
TARGET_BRANCH=mybranch ENVIRONMENT_TYPE=development cicd/2-cicd/deploy-cicd.sh
```
Steps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!


- 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.
- Then, run the following command with your branch name:
```
TARGET_BRANCH=mybranch ENVIRONMENT_TYPE=development cicd/2-cicd/deploy-cicd.sh
```

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public double getTotalAudioLength() {
public void writeToAudioStream() {
if (this.audioSamples.length == 0) {
// Add a silent audio sample so we can build a valid wav file.
// TODO: Send a "No audio" signal instead
this.audioSamples = new double[] {0};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,13 @@ private void pause(double seconds) {
private void writeImageAndAudioToFile() {
this.progressPublisher.onPlay(this.audioWriter.getTotalAudioLength());
this.gifWriter.writeToGif(this.image, 0);
this.audioWriter.writeToAudioStream();
boolean shouldSendAudio = true;
if (this.audioWriter.getTotalAudioLength() == 0) {
shouldSendAudio = false;
this.outputAdapter.sendMessage(new TheaterMessage(TheaterSignalKey.NO_AUDIO, null));
} else {
this.audioWriter.writeToAudioStream();
}

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

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

HashMap<String, String> audioMessage = new HashMap<>();
audioMessage.put(URL, audioUrl);
this.outputAdapter.sendMessage(new TheaterMessage(TheaterSignalKey.AUDIO_URL, audioMessage));
if (shouldSendAudio) {
String audioUrl =
this.contentManager.writeToOutputFile(
THEATER_AUDIO_NAME, this.audioOutputStream.toByteArray(), "audio/wav");

HashMap<String, String> audioMessage = new HashMap<>();
audioMessage.put(URL, audioUrl);
this.outputAdapter.sendMessage(
new TheaterMessage(TheaterSignalKey.AUDIO_URL, audioMessage));
}
} catch (JavabuilderException e) {
// we should not hit this (caused by too many file writes)
// in normal execution as it is only called via play,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ public enum TheaterSignalKey {
// This message contains the url to an audio element
AUDIO_URL,
// Get an image from the user via Prompter
GET_IMAGE
GET_IMAGE,
// There is no audio for this Theater
NO_AUDIO
}